<template>
	<view class="container">
		<view class="header flex justify-between  padding-20 radius-10 text-center font-14 font-weight-1000">
			<view>
				<view> {{$toFiexd(data.tabel.totalOrderMoney||0.00,2)}} </view>
				<view> 总货款 </view>
			</view>
			<view>
				<view> {{$toFiexd(data.tabel.freezeMoney||0.00,2)}}</view>
				<view> 冻结货款 </view>
			</view>
			<view>
				<view> {{$toFiexd(data.info.money||0,2)}} </view>
				<view> 解冻货款 </view>
			</view>
		</view>
		<view class="content  mt-20">
			<uni-segmented-control :current="data.current" :values="data.items" :style-type="'text'" active-color="#FF1542" @clickItem="onClickItem" />
			<view class="list padding-20">
				<empty v-if="data.list.length==0"></empty>
				<view class="item pb-10 mb-10" v-for="item in data.list">
					<view class="flex justify-between">
						<view class="font-14 font-weight-1000">
							{{item.name}} {{item.mobile}}
						</view>
						<view class="font-18 font-weight-1000" :style="{color:item.take==0?(item.prizes<2?'red':'#7fff00'):(item.state>=3?'#7fff00':'red')}" >
							{{$toFiexd(item.money,2)}}
						</view>
					</view>
					<view class="flex justify-between mt-5" style="color: #999;">
						<view class="font-13 textsl1">
							{{item.goods[0].name}}
						</view>
						<view class="font-13">
							{{item.take==0?(item.prizes<2?'未解冻':'已解冻'):(item.state>=3?'已解冻':'未解冻')}}
						</view>
					</view>
					<view class="flex justify-between mt-5" style="color: #999;">
						<view class="font-12">
							订单：{{item.order}}
						</view>
						<view class="font-12">
							{{$clearTime(item.pay_time)}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {ref,reactive,getCurrentInstance} from "vue";
	import {onLoad,onShow,onPullDownRefresh,onReachBottom} from "@dcloudio/uni-app";
	const {proxy} = getCurrentInstance();
	const data = reactive({
		current:0,
		items: ['全部货款', '冻结货款', '解冻货款'],
		info:{},
		list:[],
		page:0,
		pages:1,
		size:10,
		tabel:{}
	})
	onLoad((option)=>{
	})
	onShow(()=>{
		data.info=uni.getStorageSync('businessDetail')
		data.page=0
		data.pages=1
		data.list=[]
		getOrderList()
		proxy.$SHOPrequest({
			url: `business/analysis/`,
			method: 'get',
			success(res) {


					data.tabel = res.data


			}
		})
	})
	onPullDownRefresh(()=> {
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1000);
		})
	onReachBottom(()=>{
		getOrderList()
		console.log('onReachBottom')
	})

	function onClickItem(e){
		console.log(e.currentIndex)
		if (data.current !== e.currentIndex) {
			data.current = e.currentIndex
			data.page=0
			data.pages=1
			data.list=[]
			getOrderList()
		}
	}
	function getOrderList (){
		if(data.page<data.pages){
			data.page++
			proxy.$SHOPrequest({
				url: `business/getOrderList/?page=${data.page}&size=${data.size}&prizes=${data.current-1}`,
				method: 'get',
				success(res) {
					console.log(res.data.data)
					if(res.data.data!='null'){
						res.data.data.forEach(item=>{
							data.list.push(item)
						})

						data.pages = Math.ceil(res.data.total / data.size)
					}

				}
			})
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #fff;
	}
	.container{
		background-image: url('https://img.fubaozx.cn/static/oldImg/16995089089745.png');
		background-repeat: no-repeat;
		background-size: 100%;
		padding: 20px 0;
		.header{
			background-color: #fff;
			margin: 0 20px;
			box-shadow: 0 5px 5px 0 #eee;
		}
		.content{
			background-color: #fff;
			box-shadow: 0 -5px 5px 0 #eee;
			.list{
				border-top: 1px solid #ccc;
				.item{

					border-bottom: 1px solid #ccc;
				}
			}
		}
	}
</style>
